/*
#include<bits/stdc++.h>
using namespace std;
string s;
int k;
char c1, c2;
int main()
{
  int count = 0;
  scanf("%d", &k);
  cin >> s;
  cin >> c1 >> c2;
  for (int i = 0; i < s.size(); i ++)
  {
    for (int j = i + 1; j < s.size(); j ++)
    {
      if (s[i] == c1 && s[j] == c2 && (abs(j - i) + 1 >= k))
      {
        count ++;
      }
    }
  }
  cout << count;
  return 0;
}
*/
/*
#include <bits/stdc++.h> 
using namespace std;
int K;
long long ans=0,c1_sum=0;
string S;
char c1,c2;
int main(){
    cin>>K>>S>>c1>>c2;
    for(int i=K-1,j=0;i<S.length();i++,j++){
        if(S[j]==c1) c1_sum++;
        if(S[i]==c2) ans+=c1_sum;
    }
    cout<<ans;
    return 0;
}
*/
#include<bits/stdc++.h>
int main()
{
    int s[100] = {5, 6, 8, 6, 9, 1, 6, 1, 2, 4, 9, 1, 9, 8, 2, 3, 6, 4, 7, 7, 5, 
    9, 5, 0, 3, 8, 7, 5, 8, 1, 5, 8, 6, 1, 8, 3, 0, 3, 7, 9, 2, 7, 0, 5, 8, 
    8, 5, 7, 0, 9, 9, 1, 9, 4, 4, 6, 8, 6, 3, 3,8, 5, 1, 6, 3, 4, 6, 7, 0, 7, 
    8, 2, 7, 6, 8, 9, 5, 6, 5, 6, 1, 4, 0, 1, 0, 0, 9, 4, 8, 0, 9, 1, 2, 8, 5, 
    0, 2, 5, 3, 3};
    int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    int ans = 0;
    for (int i = 1; i <= 12; ++i)
    {
        for (int j = 1; j <= days[i]; ++j)
        {
            char str[10] = { 2,0,2,3 };
            if (i < 10)
            {
                str[4] = 0;
                str[5] = i;
            }
            else
            {
                str[4] = i / 10;
                str[5] = i % 10;
            }
            if (j < 10)
            {
                str[6] = 0;
                str[7] = j;
            }
            else
            {
                str[6] = j / 10;
                str[7] = j % 10;
            }
            int k = 0;
            for (int v = 0; v < 100; v ++)
            {
                if (s[v] == str[k])
                {
                    k++;
                }
            }
            if (k >= 8)
            {
                ans++;
            }
        }
    }
    printf("%d", ans);
    return 0;
}
